1 00:00:00,480 --> 00:00:02,960 Hello and welcome to this lecture. 2 00:00:03,120 --> 00:00:11,820 In this lecture we'll be creating event listeners and handlings the event listeners will listen out 3 00:00:12,180 --> 00:00:22,350 for Wayne the key up button or keyboard hero is suppressed or when the key down button or hour is press 4 00:00:22,650 --> 00:00:25,330 the event listeners will listen up for that. 5 00:00:25,520 --> 00:00:31,560 Once they pick that up it pass that information to the event handler. 6 00:00:31,710 --> 00:00:38,660 They'll actually fire up the code to respond to those presses those key presses. 7 00:00:38,910 --> 00:00:47,270 So let's go ahead and create the event listeners and handlers are right. 8 00:00:47,280 --> 00:00:50,460 This is the javascript so far. 9 00:00:50,460 --> 00:00:58,350 We're going to create the event listener just underneath the variables where the variables are so to 10 00:00:58,380 --> 00:01:08,460 create these event handlers an event listeners will respond to the activity of the paddle. 11 00:01:08,670 --> 00:01:16,110 So when there is the key are pressed all the key down to suppress these activities will relate to the 12 00:01:16,110 --> 00:01:27,310 paddle so to create event listener will type in document dot add event listener So b. 13 00:01:42,570 --> 00:01:45,810 All right so document dot add event list. 14 00:01:45,810 --> 00:01:47,550 Notice the camel case here. 15 00:01:47,610 --> 00:01:57,870 Lower case upper case and then upper case or 8 and then we need to pass it a couple of parameters. 16 00:01:58,650 --> 00:02:05,790 So put the parent this is there and the first value week on past this hour. 17 00:02:05,910 --> 00:02:12,520 Event listener is the text key down. 18 00:02:18,070 --> 00:02:21,410 All in lower case. 19 00:02:21,870 --> 00:02:31,270 And then the next value when it's a pass is the actual event handler that will handle the event so call 20 00:02:31,270 --> 00:02:31,690 it 21 00:02:34,190 --> 00:02:38,400 key down. 22 00:02:40,280 --> 00:02:40,680 Glad. 23 00:02:40,680 --> 00:02:44,150 Notice there's no quotes around it. 24 00:02:44,320 --> 00:02:47,000 All saw it's come well case. 25 00:02:48,520 --> 00:02:49,830 Comma. 26 00:02:49,930 --> 00:02:55,800 Now we have to give you the value of starting value and the value will be false. 27 00:02:55,840 --> 00:02:58,330 It's a boolean value. 28 00:02:58,750 --> 00:03:03,370 Falls means bad when the keys are not pressed. 29 00:03:03,370 --> 00:03:07,120 There is no activity hansis set to force. 30 00:03:07,430 --> 00:03:11,110 So a semicolon there to end that. 31 00:03:11,110 --> 00:03:20,800 Next we going to create an event listener to listen for the key up when the key when the key button 32 00:03:20,860 --> 00:03:26,200 hole keyboard arrow is pressed with the listener for that sort of module. 33 00:03:26,200 --> 00:03:33,890 I'll just copy this code here and drop it pasted and just change a few values. 34 00:03:34,030 --> 00:03:39,830 So all I need to change here is this to harp. 35 00:03:40,780 --> 00:03:49,590 So when the key a button is pressed change that to upswell. 36 00:03:51,090 --> 00:03:58,330 No it is so come or case and the value is a boolean value salthill force when there is no activity. 37 00:03:58,990 --> 00:04:06,160 So at the moment there is some activity when that when the key are button or is pressed on the keyed 38 00:04:06,550 --> 00:04:12,820 button on our espress that indicates some activities and this value is no longer false. 39 00:04:12,830 --> 00:04:16,340 So who's on the force when there is no action or does not. 40 00:04:16,330 --> 00:04:19,410 None of the keys are pressed. 41 00:04:20,030 --> 00:04:30,910 All right now that we have created the event handler and listener in their necks lecture we will create 42 00:04:31,090 --> 00:04:40,880 the function that is the activity that will happen once the key of Paul key down has been press. 43 00:04:40,910 --> 00:04:47,200 We need to create a function to actually respond and do something to that key press so we'll do that 44 00:04:47,230 --> 00:04:49,040 in the next lecture. 45 00:04:49,180 --> 00:04:50,770 Thank you so much for it. 46 00:04:50,830 --> 00:04:52,290 Bye for now.